package com.minimalist.lindi.mapper;

import com.minimalist.common.entity.lindi.po.LindiIndexChangeRecord;
import com.minimalist.common.entity.lindi.vo.indexchangerecord.LindiIndexChangeRecordQueryVO;
import com.minimalist.common.entity.lindi.vo.indexchangerecord.LindiIndexChangeRecordVO;
import com.mybatisflex.core.BaseMapper;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;

/**
 * 林地指标平台_林地指标变更记录表 映射层。
 *
 * @author 11987
 * @since 2025-05-13
 */
public interface LindiIndexChangeRecordMapper extends BaseMapper<LindiIndexChangeRecord>{

    /**
     * 根据记录ID查询指标变更记录信息。
     *
     * @param indexChangeRecordId 记录ID
     * @return 指标变更记录信息
     */
    default LindiIndexChangeRecord selectIndexChangeRecordByIndexChangeRecordId(
            Long indexChangeRecordId){
        return selectOneByQuery(QueryWrapper.create().eq(
                LindiIndexChangeRecord::getIndexChangeRecordId, indexChangeRecordId));
    }

    /**
     * 根据查询条件分页查询指标变更记录列表。
     *
     * @param queryVO 查询条件
     * @return 分页列表
     */
    default Page<LindiIndexChangeRecord> selectPageIndexChangeRecordList(
            LindiIndexChangeRecordQueryVO queryVO){
        return paginate(queryVO.getPageNum(), queryVO.getPageSize(),
                QueryWrapper.create().like(LindiIndexChangeRecord::getTownName
                                , queryVO.getTownName())
                        .eq(LindiIndexChangeRecord::getTradeApplicationId
                                , queryVO.getTradeApplicationId()));
    }

    /**
     * 根据交易申请ID和镇街名称查询指标变更记录信息。
     *
     * @param recordVO 指标变更记录信息
     * @return 指标变更记录信息
     */
    default LindiIndexChangeRecord selectIndexChangeRecordByTradeApplicationIdAndTownName
    (LindiIndexChangeRecordVO recordVO){
        return selectOneByQuery(QueryWrapper.create().eq(
                        LindiIndexChangeRecord::getTradeApplicationId
                        , recordVO.getTradeApplicationId())
                .eq(LindiIndexChangeRecord::getTownName, recordVO.getTownName()));
    }
}
